Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

axe-playwright

Package Overview
Dependencies
Maintainers
2
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

axe-playwright

Custom Playwright commands to inject axe-core and test for a11y

  • 1.2.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
259K
increased by3.03%
Maintainers
2
Weekly downloads
 
Created

What is axe-playwright?

The axe-playwright npm package is a tool that integrates the axe-core accessibility testing engine with Playwright, allowing developers to automate accessibility testing for web applications. It helps identify and fix accessibility issues by running axe-core checks within Playwright tests.

What are axe-playwright's main functionalities?

Automated Accessibility Testing

This feature allows you to perform automated accessibility testing on web pages. The code sample demonstrates how to launch a browser using Playwright, navigate to a web page, inject the axe-core library, and run accessibility checks.

const { chromium } = require('playwright');
const { injectAxe, checkA11y } = require('axe-playwright');

(async () => {
  const browser = await chromium.launch();
  const page = await browser.newPage();
  await page.goto('https://example.com');
  await injectAxe(page);
  const results = await checkA11y(page);
  console.log(results);
  await browser.close();
})();

Customizable Accessibility Checks

This feature allows you to customize the accessibility checks by specifying options such as WCAG levels. The code sample shows how to run accessibility checks with specific WCAG tags.

const { chromium } = require('playwright');
const { injectAxe, checkA11y } = require('axe-playwright');

(async () => {
  const browser = await chromium.launch();
  const page = await browser.newPage();
  await page.goto('https://example.com');
  await injectAxe(page);
  const options = { runOnly: { type: 'tag', values: ['wcag2a', 'wcag2aa'] } };
  const results = await checkA11y(page, null, options);
  console.log(results);
  await browser.close();
})();

Integration with Playwright Test Runner

This feature allows you to integrate accessibility checks directly into Playwright's test runner. The code sample demonstrates how to write a Playwright test that includes an accessibility check and asserts that there are no violations.

const { test, expect } = require('@playwright/test');
const { injectAxe, checkA11y } = require('axe-playwright');

test('Accessibility test', async ({ page }) => {
  await page.goto('https://example.com');
  await injectAxe(page);
  const results = await checkA11y(page);
  expect(results.violations.length).toBe(0);
});

Other packages similar to axe-playwright

Keywords

FAQs

Package last updated on 15 Feb 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc